/**
 * 
 */
package com.bluedon.ism.commons.operationlog;

import java.util.HashMap;
import java.util.Map;

/**
 * 日志注释信息里用提供模板解析
 * 变量栈
 */
public class LogValueStack {
	
	private static ThreadLocal<LogValueStack> threadLocal = new ThreadLocal<LogValueStack>();
	
	private Map<String, Object> attr = new HashMap<String, Object>();
	
	public static LogValueStack getContext(){
		LogValueStack context = threadLocal.get();
		if(context == null   ){
			context = new LogValueStack();
			threadLocal.set(context);
		}
		return context;
	}
	
	public static void destory() {
	    LogValueStack context = threadLocal.get();
	    if (context != null) {
	        threadLocal.set(null);
	        context = null;
	    }
	}
	 
	public Object get(String key){
		return attr.get(key);
	}
	
	public void put(String key, Object value){
		attr.put(key, value);
	}
	
	public Map<String, Object> getAttr(){
		return attr;
	}
}
